<template>
	<view class="pb20">
		<view class="">
			<orgD :data="data" />
		</view>
		<view class="radius20 bg-fff m20 p20 pb26" v-if="data.coupon&&data.coupon.length">
			<view class=" flex">
				<view class="fs28 fw-700 bottom pb6">优惠券</view>
			</view>
			<view class="mt20 ">
				<scroll-view scroll-x class="nowrap">
					<view v-for="(item,index) in data.coupon" :key="index" class="dib w670 mr20">
						<coupon :data="item" receive />
					</view>
				</scroll-view>
			</view>
		</view>
		<view class="flex row-around col-top mt30">
			<view v-for="(item,index) in list" :key="index" class="flex flex-col " @click="current = index">
				<view class="">
					{{item.name}}
				</view>
				<view class="h10 w10 radius bg-zs mt12" v-if="current==index"></view>
			</view>
		</view>

		<!-- <view class="m20 flex ">
			<view class="color-666 fs26 ">
				全部医院
			</view>
			<image src="/static/img/index/sx.png" class="h18 w18 ml16" mode=""></image>
		</view> -->

		<view class="" v-if="current == 0">
			<serviceList :list="service" :organ_id="$params.organ_id" />
		</view>
		<view class="" v-else-if="current == 1">
			<orgList :list="master" tch />
		</view>
		<view class="" v-else-if="current == 2">
			<view class="bg-fff radius12 m20">
				<view class="p20 pt30 bg-fff radius20 flex flex-wrap ">
					<view v-for="(item,index) in data.comment_word" :key="index" @click="comment_word=item"
						class="bg-f8f px28 py12 radius32 mr30 mb24 color-999"
						:class="comment_word==item?'on color-zs':''">
						{{item}}
					</view>
				</view>
				<commentList :list="comment" />
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [{
						name: '服务项目',
					},
					{
						name: '陪诊师',
					},
					{
						name: '用户评价',
					},
				],
				current: 0,

				data: '',
				service:[],
				master: [],

				comment: [],
				comment_word: ''
			};
		},
		watch: {
			comment_word() {
				this.organComment()
			},
			current(){
				this.getList()
			},
		},
		onLoad() {
			this.getData()
			this.getList()
		},
		onReachBottom() {
			this.getList('down')
		},
		methods: {
			getData() {
				this.$request('/member/search/organInfo', this.$params).then(res => {
					let data = res.data
					this.data = data
					uni.setNavigationBarTitle({
						title:data.name
					})
					this.shareData.title=this.$config.shop_title+' 陪诊机构:'+data.name
				})
			},
			getList(e = '') {
				if (this.current == 0) {
					this.organService(e)
				} else if (this.current == 1) {
					this.organMaster(e)
				} else {
					this.organComment(e)
				}
			},
			organComment(e) {
				e == 'down' ? this.page++ : this.page = 1
				let params = {
					...this.$params,
					comment_word: this.comment_word,
					page: this.page,
				}
				this.$request('/member/search/organComment', params).then(res => {
					let list = res.data.data
					e == 'down' ? this.comment.push(...list) : this.comment = list
				})
			},
			organService(e) {
				e == 'down' ? this.page++ : this.page = 1
				let params = {
					...this.$params,
					page: this.page,
				}
				this.$request('/member/search/organService', params).then(res => {
					let list = res.data.data
					e == 'down' ? this.service.push(...list) : this.service = list
				})
			},
			organMaster(e) {
				e == 'down' ? this.page++ : this.page = 1
				let params = {
					...this.$params,
					page: this.page,
				}
				this.$request('/member/search/organMaster', params).then(res => {
					let list = res.data.data
					e == 'down' ? this.master.push(...list) : this.master = list
				})
			},
		},
	}
</script>

<style lang="scss">
	.color-FF704B {
		color: #FF704B;
	}
</style>
